(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Script/WXGamePlatform.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, 'b62b6E6yu9KqrbbpG+cxzuH', 'WXGamePlatform', __filename);
// Script/WXGamePlatform.ts

Object.defineProperty(exports, "__esModule", { value: true });
var Platform = require("./Platform");
// import httpUtils = require("./XmlHttpTool"); //可以是js也可以是ts
var DefaultPlatform = /** @class */ (function (_super) {
    __extends(DefaultPlatform, _super);
    function DefaultPlatform() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DefaultPlatform.prototype.init = function (bg) {
        this.bg = bg;
        this.params = {
            devid: 6, devtype: 2, appid: "com.taoqi001.mp_marmot",
            appver: 300, token: "8bba0bcbdd4b6a768c90aa3cf4ea7283"
        };
    };
    DefaultPlatform.prototype.getWeXinToken = function (callback) {
        wx.login({
            success: function (res) {
                callback(res["code"]);
            },
            fail: function (res) {
                console.log('微信登录失败');
            },
            complete: function (res) { }
        });
    };
    DefaultPlatform.prototype.getWeXinUserInfo = function (callUser) {
        var _this = this;
        var btnX = (cc.winSize.width - this.bg.startGameBtn.node.width) / 2;
        var btnY = (cc.winSize.height - this.bg.startGameBtn.node.height) / 2 - this.bg.startGameBtn.node.y;
        var system = wx.getSystemInfoSync();
        var width = system.screenWidth;
        var height = system.screenHeight;
        var thisWidth = cc.winSize.width;
        var thisHeight = cc.winSize.height;
        console.log("x.y", btnX, btnY);
        var button = wx.createUserInfoButton({
            type: 'text',
            text: '',
            style: {
                left: btnX / thisWidth * width,
                top: btnY / thisHeight * height,
                width: this.bg.startGameBtn.node.width / thisWidth * width,
                height: this.bg.startGameBtn.node.height / thisHeight * height,
                lineHeight: 40,
                backgroundColor: '#00000000',
                color: '#ffffff',
                textAlign: 'center',
                fontSize: 16,
                borderRadius: 4
            }
        });
        this.button = button;
        this.button.show();
        this.button.onTap(function (res) {
            _this.bg.enterGameViewClick();
            button.hide();
            console.log("全局2", window["httppost"]);
            window["httppost"].NhttpPost("/users/save_user_info", {
                avatar: res.userInfo.avatarUrl,
                name: res.userInfo.nickName,
                gender: res.userInfo.gender
            }, function (userres) {
                callUser(userres);
                console.log("用户信息", userres);
            });
        });
    };
    DefaultPlatform.prototype.wxShareMessage = function () {
        var height = canvas.height;
        var width = canvas.width;
        var originH = (cc.winSize.height - 634) / 2 - 109;
        var y = height * originH / cc.winSize.height;
        wx.shareAppMessage({
            title: '淘气打地鼠大作战',
            imageUrl: canvas.toTempFilePathSync({
                width: width,
                height: height - y,
                x: 0,
                y: y
            }),
            success: function (res) {
                console.log("转发成功");
            },
            fail: function (failres) {
                console.log("转发失败");
            }
        });
        var that = this;
        window["httppost"].NhttpPost("/marmot/share", {}, function (sharees) {
            console.log("分享调用", sharees);
            that.bg.getUserInfoMessage();
        });
    };
    DefaultPlatform.prototype.setStorage = function (obj) {
        wx.setStorageSync(obj['key'], obj['value']);
        this.params["token"] = obj['value'];
        console.log("改变的字典", this.params);
    };
    DefaultPlatform.prototype.getStorage = function (key) {
        return wx.getStorageSync(key);
    };
    DefaultPlatform.prototype.checkSession = function () {
        var _this = this;
        wx.checkSession({
            success: function (res) {
                //直接登录
                var data = wx.getStorageSync("wxtoken");
                _this.params["token"] = data;
                _this.bg.loginMouse();
                console.log("未过期", res);
            },
            fail: function (res) {
                console.log("已过期", res);
                //重新登录
                _this.bg.loginGame();
            },
            complete: function (res) { }
        });
    };
    return DefaultPlatform;
}(Platform));
exports.default = DefaultPlatform;

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=WXGamePlatform.js.map
        